<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/add.css">

</head>

<body>

    <div class="container">

        <div class="form-inline">
            <h2 style="text-align: left; margin-left: 10px;">
                <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" class="bi bi-person-add" viewBox="0 0 16 16">
                    <path fill-rule="evenodd" d="M12.5 16a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm.5-5a.5.5 0 0 0-1 0v1h-1a.5.5 0 0 0 0 1h1v1a.5.5 0 0 0 1 0v-1h1a.5.5 0 0 0 0-1h-1v-1Zm-2-6a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM8 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"/>
                    <path d="M8.256 14a4.474 4.474 0 0 1-.229-1.004H3c.001-.246.154-.986.832-1.664C4.484 10.68 5.711 10 8 10c.26 0 .507.009.74.025.226-.341.496-.65.804-.918C9.077 9.038 8.564 9 8 9c-5 0-6 3-6 4s1 1 1 1h5.256Z"/>
                  </svg>
                <span>用户注册</span>
            </h2>
        </div>

        <form id="addUser">
            <div class="form-group">
                <label for="userName">用户名:</label>
                <input type="text" class="form-control" placeholder="请输入用户名称" id="userName" name="userName">
            </div>
            <div class="form-group">
                <label for="password">密码:</label>
                <input type="text" class="form-control" placeholder="请输入密码" id="password" name="password" />
            </div>
            <div class="form-group">
                <label for="githubUrl">GitHub网址:</label>
                <input type="text" class="form-control" placeholder="请输入GitHub网址" id="githubUrl" name="githubUrl" />
            </div>


            <div class="form-group" style="text-align: right">
                <button type="button" class="btn btn-info btn-lg" onclick="add()">确定</button>
                <button type="button" class="btn btn-secondary btn-lg" onclick="javascript:history.back()">返回</button>
            </div>
        </form>
    </div>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script>

        function add() {
            $.ajax({
                type: "get",
                url: "/user/register",
                data:$("#addUser").serialize(),
                success:function(result) {
                    if(result.code == 200 && result.data == true) {
                        alert("用户注册成功");
                        location.href = "blog_login.html";
                    }else {
                        alert("用户注册失败");
                    }
                }
            });
            
        }


    </script>
</body>

</html>